Ext.namespace('ZZExt');

ZZExt.Workspace = Ext.extend(Ext.TabPanel,{
	
	region : 'center',
	border : true,
	activeTab : 0,
	enableTabScroll : true,
	
	constructor:function(config){
		
		Ext.apply(this,config);
		
		ZZExt.Workspace.superclass.constructor.call(this,{
			margins : '0 5 2 2',
			plugins:new Ext.ux.TabCloseMenu()
		});
	},
	loadClass:function(xtype,cls,params){
		var id = 'page-' +xtype+'-'+ cls;
        var tab = this.getComponent(id);
        if(tab){
            this.setActiveTab(tab);
        }else{
           	var config = {
           		id:id,
            	xtype:xtype,
            	closable:true
           	};
           	Ext.apply(config,params);
           	tab = this.add(config);
            this.setActiveTab(tab);
        }
    	var _params = (params==null?null:params.ZZExtParams);
        tab.fireEvent('ZZExt.init',_params);
        return tab;
	},
	removeClass:function(xtype,cls){
		var id = 'page-' +xtype+'-'+ cls;
		var tab = this.getComponent(id);
        if(tab){
            this.removeTab(tab);
        } else {
        	Ext.Msg.alert('提示','已关闭!');
        }
	}
	
})